package com.eastfair.certificate.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 制证订单
 * </p>
 *
 * @author ligang
 * @date 2023-07-07
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CertificateOrderDrawTypeEnum", description = "领取方式:#{MAKE:预约领取;SITE:现场领取;-枚举")
public enum CertificateOrderDrawTypeEnum implements BaseEnum {

    /**
     * MAKE="预约领取"
     */
    MAKE("预约领取"),
    /**
     * SITE="现场领取"
     */
    SITE("现场领取"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static CertificateOrderDrawTypeEnum match(String val, CertificateOrderDrawTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static CertificateOrderDrawTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(CertificateOrderDrawTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "MAKE,SITE", example = "MAKE")
    public String getCode() {
        return this.name();
    }

}
